<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
</head>
<body>
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-body">
            <div class="layui-row">
                <form class="layui-form" lay-filter="myform" id="myform">
                    <input type="reset" id="btReset" class="layui-hide" >
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">名称</label>
                            <div class="layui-input-inline">
                                <input type="text" name="name" id="name"  autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <div class="layui-btn-group">
                                <button type="button" class="layui-btn layui-btn-primary" data-type="query"><i class="layui-icon">&#xe615;</i>查询</button>
                                <button type="button" class="layui-btn layui-btn-primary" data-type="resetBtn"><i class="layui-icon">&#xe669;</i>重置</button>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
            <div class="layui-row layui-col-space5">
                <table class="layui-hide"  id="main-table" lay-filter="main-table"></table>
            </div>
        </div>
    </div>
</div>

<script th:inline="none"></script>
<script>
    layui.use(['table','form','element'], function(){
        var table = layui.table,
            form = layui.form;
        table.render({
            elem: '#main-table'
            ,height: '400px'
            ,url: 'knowledgePoint/getPageList'
            ,title: '知识点列表'
            ,page: true
            ,cols: [
                [
                    {type: 'checkbox'},
                    {type: 'numbers'}
                    ,{field: 'id', title: "ID",hide:true,width:180}
                    ,{field: 'name', title: "知识点名称",width:280}
                ]
            ]
            ,done:function(){
                enableRowClick(table,form,'main-table',"main-table");
            }
        });

        var $ = layui.$, active = {
            query: function(){

                table.reload("main-table",{where:{name:$("#name").val()}})
            },
            resetBtn:function () {
                $("#btReset").click();

            }
        };
        $('.layui-form .layui-btn').on('click', function(){
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
        window.getIds = function (){
            var checkStatus = table.checkStatus('main-table');
            let data = checkStatus.data;
            let ids = [];
            for(var i=0;i<data.length;i++){
                ids.push({id:data[i].id,name:data[i].name});
            }
            return ids;
        }


    });


</script>
<script type="text/html" id="rowtools">
    <a class="layui-btn layui-btn-xs" lay-event="select">选择</a>
</script>
</body>
</html>